/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cronus.server;

import javax.swing.*;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.File;
import java.awt.Dimension;

/**
 *
 * @author Youri
 */
public class Popupscreen extends JFrame{
    private JTextArea popuptext;
    private File file;
    private StringBuffer buffer;
    private BufferedReader reader = null;
    private JPanel panel;
    private JScrollPane scrollpane;
    
    
    
    public Popupscreen(String filepath){
        panel = new JPanel();
        setSize(640, 480);
        popuptext = new JTextArea(33,55);
        popuptext.setLineWrap(true);
        popuptext.setEditable(false);
        
        
        setContentPane(panel);
        scrollpane = new JScrollPane(popuptext);        
        scrollpane.setPreferredSize(new Dimension(620, 430));
        
        panel.add(scrollpane);
        popuptext.setEditable(false);
        
        file = new File(filepath);
        buffer = new StringBuffer();
        
        try {
            reader = new BufferedReader(new FileReader(file));
            String text = null;
            
            while((text = reader.readLine())!= null){
            buffer.append(text)
            .append(System.getProperty("line.separator"));
            }
            
        } catch (java.io.FileNotFoundException e) {
                e.printStackTrace();  
        } catch (java.io.IOException e) {
                e.printStackTrace();
            } finally {
                try {
                    if (reader != null) {
                    reader.close();
                    }
                } catch (java.io.IOException e) {
                    e.printStackTrace();
                }
}
        popuptext.setText(buffer.toString());   
    }
    
}
